/*
 * CAppStateIntro.cpp
 *
 *  Created on: 24/12/2012
 *      Author: Dalton
 */
#include "CAppStateIntro.h"
#include "CAppStateManager.h"

CAppStateIntro CAppStateIntro::instance;

CAppStateIntro::CAppStateIntro() {
	surfLogo = NULL;
	startTime = 0;

}

void CAppStateIntro::onActivate() {
	if((surfLogo = CSurface::onLoad(".//data/imgs/intro.png")) == NULL){
		return;
	}
	startTime = SDL_GetTicks();

}

void CAppStateIntro::onDeactivate() {
	if(surfLogo){
		SDL_FreeSurface(surfLogo);
		surfLogo = NULL;
	}

}

void CAppStateIntro::onLoop() {
	if(startTime + 1000 < SDL_GetTicks()){
		CAppStateManager::setActiveAppState(APPSTATE_MENU);
	}

}

void CAppStateIntro::onRender(SDL_Surface* surfDisplay) {
	if(surfLogo){
		CSurface::onDraw(surfDisplay, surfLogo,0,0);
	}

}

CAppStateIntro* CAppStateIntro::getInstance() {
    return &instance;
}



